﻿@model Property4U.Models.Request

@{
    ViewBag.Title = "Create";
}

<div class="row">
    <!-- Page Header -->
    <div class="col-lg-12">
        <h1 class="page-header">@ViewBag.Title</h1>
    </div>
    <!--End Page Header -->
</div>

<link rel="stylesheet" type="text/css" href="~/Content/jquery.ui.timepicker.css">

@using (Html.BeginForm()) 
{
    @Html.AntiForgeryToken()
    
    <div class="form-horizontal">
        <h4>Request</h4>
        <hr />
        @Html.ValidationSummary(true, "", new { @class = "text-danger" })
        <div class="form-group">
            @Html.LabelFor(model => model.MemberID, "MemberID", htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.DropDownList("MemberID", (SelectList)ViewBag.MemberIDList, String.Empty, htmlAttributes: new { @class = "form-control" })
                @Html.ValidationMessageFor(model => model.MemberID, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.PropertyID, "PropertyID", htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.DropDownList("PropertyID", (SelectList)ViewBag.PropertyIDList, String.Empty, htmlAttributes: new { @class = "form-control" })
                @Html.ValidationMessageFor(model => model.PropertyID, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.Title, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.Title, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.Title, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.Description, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.Description, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.Description, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.VisitingDate, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.VisitingDate, new { htmlAttributes = new { @class = "form-control VisitingDate", @readonly = "readonly", @placeholder = "Pick Visiting Date" } })
                @Html.ValidationMessageFor(model => model.VisitingDate, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.VisitingTime, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.VisitingTime, new { htmlAttributes = new { @class = "form-control", @readonly = "readonly", @placeholder = "Pick Visiting Time"  } })
                @Html.ValidationMessageFor(model => model.VisitingTime, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.RequestOn, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.RequestOn, new { htmlAttributes = new { @class = "form-control", @Value = ViewBag.RequestOn, @readonly = "readonly" } })
                @Html.ValidationMessageFor(model => model.RequestOn, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.RequestStatus, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EnumDropDownListFor(model => model.RequestStatus, "Pending", htmlAttributes: new { @class = "form-control", @disabled = "disabled" })
                @Html.HiddenFor(model => model.RequestStatus, new { id = "RequestStatus", @Value = ViewBag.RequestStatus })
                @Html.ValidationMessageFor(model => model.RequestStatus, "", new { @class = "text-danger" })
            </div>
        </div>

        @Html.HiddenFor(model => model.LastEdit)

        <div class="form-group">
            <div class="col-md-offset-2 col-md-10">
                <input type="submit" value="Create" class="btn btn-default" />
            </div>
        </div>
    </div>
}

<div>
    @Html.ActionLink("Back to List", "Index")
</div>

@section scripts {
<script type="text/javascript" src="~/Scripts/jquery.ui.timepicker.js"></script>
    <script type="text/javascript">
        $(function () {
            $("#VisitingDate").datepicker({
                defaultDate: "+1w",
                minDate: new Date(),
                dateFormat: 'yy-mm-dd',
                changeMonth: true,
                numberOfMonths: 2
            });
        });
        $('#VisitingTime').timepicker({
            showPeriod: true,
            showLeadingZero: true
        });

        @* Check url parameter reportAbuse isNumeric and set defualts EnumDropDownListFor  *@
        $(function () {
            if ($.isNumeric("@Request.Params["PID"]")) {
                $("#PropertyID").val('@Request.Params["PID"]');
        }
        });
    </script>
}

